<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>{$current['title']}-{$Think.CONFIG.sitename}</title>

    <link href="__PUBLIC__/static/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="__PUBLIC__/static/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="__PUBLIC__/static/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="__PUBLIC__/static/css/animate.min.css" rel="stylesheet">
    <include file="Public/commoncss" />
    <link href="__PUBLIC__/static/css/plugins/switchery/switchery.css" rel="stylesheet">
    <link href="__PUBLIC__/static/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css" rel="stylesheet">
</head>

<body class="gray-bg top-navigation">
<div id="wrapper">
    <div id="page-wrapper" class="gray-bg">
        <div class="row border-bottom white-bg">
            <include file="Public/header" />
        </div>
        <div class="wrapper wrapper-content">
            <div class="row">
                <div class="col-sm-3">
                    <div class="ibox float-e-margins">
                        <include file="Public/setnav" />
                    </div>
                </div>
                <div class="col-sm-9 animated fadeInRight">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title"><h4>{$current['title']}</h4></div>
                        <div class="ibox-content">
                            <form class="form-horizontal m-t" action="{:U('update')}" id="myForm">
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">用户组名称：</label>
                                    <div class="col-sm-10">
                                        <input  name="title" class="form-control" type="text" value="" datatype="*3-16" placeholder="用户组名称：CEO/项目经理"  nullmsg="请填写用户组名称！" errormsg="用户组名称至少3个字符！" sucmsg="用户组名称验证通过！" autocomplete="off">
                                        <span class="help-block m-b-none Validform_checktip"></span>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">是否启用：</label>
                                    <div class="col-sm-10">
                                        <input type="checkbox" name="status" class="js-switch" value="1" checked/>
                                        <span class="help-block m-b-none">yes为开启，no为关闭！</span>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">权限配置：</label>
                                    <div class="col-sm-10">
                                        <volist name="rule" id="v">
                                            <div class="panel panel-default">
                                                <div class="panel-heading">
                                                    <div class="checkbox checkbox-success checkbox-inline">
                                                        <input id="inlineCheckbox{$v['id']}" name="rules[]"  class="father"  value="{$v['id']}" type="checkbox">
                                                        <label for="inlineCheckbox{$v['id']}"> {$v['title']} </label>
                                                    </div>
                                                </div>
                                                <notempty name="v.children">
                                                    <div class="panel-body">
                                                        <div class="checkbox checkbox-success checkbox-inline">
                                                            <volist name="v.children" id="vv">
                                                                <div class="checkbox checkbox-success checkbox-inline" style="width:160px;">
                                                                    <input id="inlineCheckbox{$vv['id']}" class="children" name="rules[]"  value="{$vv['id']}" type="checkbox">
                                                                    <label for="inlineCheckbox{$vv['id']}"> {$vv['title']} </label>
                                                                </div>
                                                                <volist name="vv.children" id="vvv">
                                                                    <div class="checkbox checkbox-success checkbox-inline" style="width:160px;">
                                                                        <input id="inlineCheckbox{$vvv['id']}" class="children"  name="rules[]"  value="{$vvv['id']}" type="checkbox">
                                                                        <label for="inlineCheckbox{$vvv['id']}"> {$vvv['title']} </label>
                                                                    </div>
                                                                    <foreach name="vvv.children" item="vol">
                                                                        <div class="checkbox checkbox-success checkbox-inline" style="width:160px;">
                                                                            <input id="inlineCheckbox{$vol['id']}" class="children"  name="rules[]"  value="{$vol['id']}" type="checkbox">
                                                                            <label for="inlineCheckbox{$vol['id']}"> {$vol['title']} </label>
                                                                        </div>
                                                                        <foreach name="vol.children" item="voll">
                                                                            <div class="checkbox checkbox-success checkbox-inline" style="width:160px;">
                                                                                <input id="inlineCheckbox{$voll['id']}" class="children"  name="rules[]"  value="{$voll['id']}" type="checkbox">
                                                                                <label for="inlineCheckbox{$voll['id']}"> {$voll['title']} </label>
                                                                            </div>
                                                                        </foreach>
                                                                    </foreach>
                                                                </volist>
                                                            </volist>
                                                        </div>
                                                    </div>
                                                </notempty>
                                            </div>
                                        </volist>

                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="col-sm-10 col-sm-offset-3">
                                        <button class="btn btn-primary" type="submit">保存用户组</button>
                                        <span class="help-block m-b-none " id="dump"></span>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>

                </div>
            </div>
        </div>
        <include file="Public/footer" />
    </div>
</div>
<include file="Public/commonjs" />
<script src="__PUBLIC__/static/js/bootstrap.min.js?v=3.3.5"></script>
<script src="__PUBLIC__/static/js/content.min.js?v=1.0.0"></script>
<script src="__PUBLIC__/static/js/plugins/switchery/switchery.js"></script>
<script src="__PUBLIC__/static/js/plugins/validate/Validform_v5.3.2.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        var elem = document.querySelector('.js-switch');
        var init = new Switchery(elem);
        defaults = {
            color          : '#64bd63'  //开关打开的颜色
            , secondaryColor : '#dfdfdf'  //开关关闭的颜色
            , className      : 'switchery'//开关的名称
            , disabled       : false      //开关是否可用
            , disabledOpacity: 0.5        //开关的透明度
            , speed          : '0.1s'     //开关的动画时间
        }
        //点击权限
        $(".children").click(function(){
            $(this).parent().parent().parent().parent().find(".father").prop("checked", true);
        })
        $(".father").click(function(){
            if(this.checked){
                $(this).parent().parent().parent().find(".children").prop("checked", true);
            }else{
                $(this).parent().parent().parent().find(".children").prop("checked", false);
            }
        })

        //提交表单
        $("#myForm").Validform({
            tiptype:function(msg,o,cssctl){
                if(!o.obj.is("form")){
                    var objtip=o.obj.siblings(".Validform_checktip");
                    cssctl(objtip,o.type);
                    objtip.text(msg);
                }else{
                    if(msg == '恭喜，用户组添加成功！'){
                        window.location.href="{:U('Group/index')}";
                    }else{
                        var objtip=o.obj.find("#dump");
                        cssctl(objtip,o.type);
                        objtip.text(msg);
                    }
                }
            },
            ajaxPost:true
        });
    })
</script>
</body>

</html>